package com.atguigu.yygh.hosp.controller.user;

import com.atguigu.yygh.common.result.R;
import com.atguigu.yygh.hosp.service.HospitalService;
import com.atguigu.yygh.hosp.service.ScheduleService;
import com.atguigu.yygh.model.hosp.Schedule;
import com.atguigu.yygh.vo.hosp.ScheduleOrderVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

/**
 * @author mgx
 * @version 1.0
 * @description: TODO
 * @date 2022/9/5 8:46
 */
@RestController
@RequestMapping("/user/hosp/schedule")
@Api(tags = {"用户系统对排班信息的管理"})
public class UserScheduleController {

    @Autowired
    private ScheduleService scheduleService;


    @ApiOperation(value = "远程调用 -- 根据排班id获取排班信息")
    @GetMapping("/{scheduleId}")
    public ScheduleOrderVo getScheduleOrderVo(@PathVariable("scheduleId")String scheduleId) {
        ScheduleOrderVo scheduleOrderVo = scheduleService.getScheduleOrderVo(scheduleId);
        return scheduleOrderVo;
    }

    @ApiOperation(value = "获取排班信息详情")
    @GetMapping("/info/{scheduleId}")
    public R getScheduleInfo(@PathVariable String scheduleId) {
        Schedule schedule = scheduleService.getScheduleInfo(scheduleId);
        return R.ok().data("schedule", schedule);
    }


    @ApiOperation(value = "排班带条件查询的聚合查询数据")
    @GetMapping("/{hoscode}/{depcode}/{pageNum}/{limit}")
    public R getSchedulePageByCondition(@PathVariable("hoscode") String hoscode,
                                        @PathVariable("depcode") String depcode,
                                        @PathVariable("pageNum") Integer pageNum,
                                        @PathVariable("limit") Integer limit) {
        Map<String, Object> map = scheduleService.getSchedulePageByCondition(hoscode,depcode,pageNum,limit);
        return R.ok().data(map);
    }

    @ApiOperation(value = "查询详情")
    @GetMapping("/{hoscode}/{depcode}/{workDate}")
    public R getScheduleDatail(@PathVariable("hoscode") String hoscode,
                               @PathVariable("depcode") String depcode,
                               @PathVariable("workDate") String workDate) {
        List<Schedule> details = scheduleService.detail(hoscode, depcode, workDate);
        return R.ok().data("details", details);
    }


}
